package com.qcxk.yuqian.rtu.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.qcxk.yuqian.rtu.entity.Instruction;
import com.qcxk.yuqian.rtu.mapper.InstructionMapper;
import com.qcxk.yuqian.rtu.service.IInstructionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.qcxk.yuqian.system.component.QueryWrapperConverter;

/**
 * @auther lp
 * @create 2021-12-07 17:37:17
 * @describe 服务实现类
 */
@Service
public class InstructionServiceImpl extends ServiceImpl<InstructionMapper, Instruction> implements IInstructionService {
    @Autowired
    private InstructionMapper instructionMapper;

    @Override
    public Page queryInstructionPage(Page page, Instruction instruction) {

        QueryWrapper<Instruction> instructionQueryWrapper = new QueryWrapper<>();
        QueryWrapperConverter.converter(instructionQueryWrapper, instruction);

        instructionQueryWrapper.orderByDesc("ctime");
        instructionMapper.selectPage(page, instructionQueryWrapper);
        return page;
    }

    @Override
    public boolean deleteInstructionById(Instruction instruction) {
        int re = instructionMapper.deleteById(instruction.getId());
        return re == 1 ? true : false;
    }
}
